/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.kmcsoft.goldshop.goldexchange.service.impl;

import com.kmcsoft.goldshop.goldexchange.service.GoldExchangeService;
import com.kmcsoft.goldshop.model.exchange.GoldExchange;
import com.kmcsoft.goldshop.model.exchange.GoldExchangeDetail;
import com.kmcsoft.goldshop.model.master.ProductGold;
import com.kmcsoft.master.defaultservice.DefaultGenericService;
import java.util.Collection;

/**
 *
 * @author kmcsoft02
 */
public class JdoGoldExchangeService extends DefaultGenericService implements GoldExchangeService {

    public GoldExchange getGoldExchangeById(Object id) {
        getPersistenceManager().getFetchPlan().addGroup("detach_GoldExchange_All");
        getPersistenceManager().getFetchPlan().addGroup("detach_GoldExchangeDetail_All");
        getPersistenceManager().getFetchPlan().setMaxFetchDepth(-1);
        return getJdoTemplate().detachCopy(getJdoTemplate().getObjectById(GoldExchange.class, id));
    }

    public Collection<ProductGold> getProductGolds() {
        getPersistenceManager().getFetchPlan().addGroup("detach_ProductGold_Unit");
        getPersistenceManager().getFetchPlan().setMaxFetchDepth(-1);
        return getJdoTemplate().detachCopyAll(getJdoTemplate().find(ProductGold.class,"productType==pType","Integer pType",ProductGold.TYPE_GOLD));
    }

    public GoldExchangeDetail getGoldExchangeDetailById(long id) {
        getPersistenceManager().getFetchPlan().addGroup("detach_GoldExchangeDetail_All");
        getPersistenceManager().getFetchPlan().setMaxFetchDepth(-1);
        return getJdoTemplate().detachCopy(getJdoTemplate().getObjectById(GoldExchangeDetail.class, id));
    }
}
